<?php
/**
 * Created by PhpStorm.
 * User: nhson219
 * Date: 10/1/2014
 * Time: 11:16 PM
 */
?>
<div class="modal fade bs-example-modal-lg" id="modal-google-register" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
    <div class="modal-dialog modal-lg">
        <div class="modal-content">
            <div style="background: #fff;" class="app-form app-signup col-lg-12 col-xs-12 col-sm-12">
            <div class="col-md-4 col-sm-4" style="margin-top: 30px;">
                <img  src="" class="image-avatar-google img-responsive" />
            </div>
            <div class="col-md-8 col-sm-8">
                <form id="form-modal-register-google" method="POST" action="<?php echo site_url('users/modalRegisterGoogle')?>" role="form">
                    <?php echo form_token()?>
                    <div class="col-md-12">
                        <h2><?php echo $this->lang->line('Register');?></h2>
                    </div>
                    <div class="col-md-12 no-padding">
                        <div class="col-md-12 col-sm-12 form-group">
                            <input type="text" name="email" id="email" class="form-control" value="<?php echo set_value('email')?>"  placeholder='Email'>
                            <span><?php echo form_error('email')?></span>
                        </div>
                        <div class="col-md-12 col-sm-12 form-group">
                            <input type="text" name="username" id="username" value="<?php echo set_value('username')?>" class="form-control" placeholder='<?php echo $this->lang->line('username')?>'>
                            <span><?php echo form_error('username')?></span>
                        </div>
                    </div>
                    <div class="form-group line-input">
                        <div class="col-md-12 col-sm-12">
                            <input type="password" name="password" id="register-google-password" value="<?php echo set_value('password')?>" class="form-control"  placeholder='<?php echo $this->lang->line('password')?>'>
                            <span><?php echo form_error('password')?></span>
                        </div>
                        <div class="col-md-12 col-sm-12">
                            <input type="password" name="confirm-password" id="modal-register-confirm-password" value="<?php echo set_value('confirm-password')?>" class="form-control" id="exampleInputEmail1" placeholder='<?php echo $this->lang->line('Confirm Password')?>'>
                            <span><?php echo form_error('confirm-password')?></span>
                        </div>
                    </div>
                    <div class="col-md-12">
                        <label class="col-lg-4 col-md-4 no-padding"><?php echo $this->lang->line("I'm looking for")?></label>
                                <span class="col-lg-4 col-md-4" style="text-align: right;">
                                    <label>
                                        <input <?php echo set_radio('role_id',1,TRUE)?> name="role_id" type="radio" value="1" >
                                        <?php echo $this->lang->line('Hire');?>
                                    </label>
                                </span>
                                <span class="col-lg-4 col-md-4">
                                    <label>
                                        <input type="radio" <?php echo set_radio('role_id',2)?> name="role_id" value="2" >
                                        <?php echo $this->lang->line('Work');?>
                                    </label>
                                </span>
                    </div>
                    <input type="hidden" value="" name="avatar-google" id="img-avatar-google" />
                    <p class="col-md-12"><?php echo $this->lang->line('Login with your google or applancer account')?></p>
                    <div class="form-group">
                        <div class="col-md-6">
                            <input type="hidden" value="1" name="buyerConfirm" />
                            <button type="submit" name="buyerConfirm" value="buyerConfirm" class="btn btn-create btn-lg col-sm-12 col-md-12 col-xs-12">
                                <i class="icon_edit"></i>
                                <?php echo $this->lang->line('Register')?>
                            </button>
                        </div>
                    </div>
                </form>
            </div>
        </div> <!-- app-form-login -->
        </div>
    </div>
</div>
<script>
    $(document).ready(function(){
        $("#form-modal-register-google").validate({
            errorElement: "span", // contain the error msg in a span tag
            errorClass: 'help-block',
            errorPlacement: function (error, element) { // render error placement for each input type
                if (element.attr("type") == "radio" || element.attr("type") == "checkbox") { // for chosen elements, need to insert the error after the chosen container
                    error.insertAfter($(element).closest('.form-group').children('div').children().last());
                } else if (element.attr("name") == "dd" || element.attr("name") == "mm" || element.attr("name") == "yyyy") {
                    error.insertAfter($(element).closest('.form-group').children('div'));
                } else {
                    error.insertAfter(element);
                    // for other inputs, just perform default behavior
                }
            },
            highlight: function (element) {
                $(element).closest('.help-block').removeClass('valid');
                // display OK icon
                $(element).closest('.form-group').removeClass('has-success').addClass('has-error').find('.symbol').removeClass('ok').addClass('required');
                $(element).closest('.form-group').find(".glyphicon-ok").remove();
                $(element).after("<span class='glyphicon glyphicon-remove form-control-feedback'></span>");
                // add the Bootstrap error class to the control group
            },
            unhighlight: function (element) { // revert the change done by hightlight
                $(element).closest('.form-group').removeClass('has-error');

                // set error class to the control group
            },
            success: function (label, element) {
                label.addClass('help-block');
                // mark the current input as valid and display OK icon
                $(element).closest('.form-group').removeClass('has-error').addClass('has-success').find('.symbol').removeClass('required').addClass('ok');
                $(element).closest('.form-group').find(".glyphicon-remove").remove();
                $(element).after("<span class='glyphicon glyphicon-ok form-control-feedback'></span>");
            },
            rules:{
                "email" : {
                    required : true,
                    email : true,
                    minlength:5,
                    remote:{
                        url: "<?php echo site_url('buyer/checkUserEmailInfo');?>",
                        type : "POST"
                    }
                },
                "password" : {
                    required : true,
                    minlength : 8
                },
                "username" : {
                    required : true,
                    minlength :5,
                    remote:{
                        url: "<?php echo site_url('buyer/checkUserNameInfo');?>",
                        type : "POST"
                    }
                },
                "confirm-password" : {
                    equalTo : "#register-google-password",
                    required : true,
                    minlength : 8
                }
            },
            messages:{
                "email":{
                    required : "<?php echo $this->lang->line('Email')." ".$this->lang->line('required') ?>",
                    email : "<?php echo $this->lang->line('Email')." ".$this->lang->line('valid_email') ?>",
                    minlength : "<?php echo $this->lang->line('Email')." ".$this->lang->line('min_length'); ?>",
                    remote :  "<?php echo $this->lang->line('Email')." ".$this->lang->line('is_unique'); ?>"
                },
                "username":{
                    required : "<?php echo $this->lang->line('Username')." ".$this->lang->line('required') ?>",
                    minlength : "<?php echo $this->lang->line('Username')." ". $this->lang->line('min_length'); ?>",
                    remote :  "<?php echo $this->lang->line('Username')." ".$this->lang->line('is_unique'); ?>"
                },
                "password":{
                    required : "<?php echo $this->lang->line('Password')." ".$this->lang->line('required') ?>",
                    minlength : "<?php echo $this->lang->line('Password')." ".$this->lang->line('min_length'); ?>"
                },
                "confirm-password":{
                    required : "<?php echo $this->lang->line('Confirm Password')." ".$this->lang->line('required') ?>",
                    equalTo : "<?php echo $this->lang->line('Confirm Password')." ".$this->lang->line('matches') ?>",
                    minlength : "<?php echo $this->lang->line('Confirm Password')." ".$this->lang->line('min_length'); ?>"
                }
            },
			


        });

    });
</script>